package com.msblearn.C_007;

import java.util.concurrent.locks.LockSupport;

public class T000_My_LockSupport {
    static Thread t1, t2;

    public static void main(String[] args) {
        String[] abc = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
        t1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                LockSupport.park();
                System.out.print(i + 1);
                LockSupport.unpark(t2);
            }
        });
        t1.start();
        t2 = new Thread(() -> {
//            LockSupport.park();
            for (int i = 0; i < 10; i++) {
                System.out.print(abc[i]);
                LockSupport.unpark(t1);
                LockSupport.park();
            }
        });

        t2.start();
    }
}
